# Bot for profile views thread
# By Cee Pee

import forumapi

def settings(settings):
	settings.add_arg("thread", type="int", help="thread ID to post in")

def main(me, options, args):
	# TODO: Doesn't work for session and cookie authentications
	profile = me.get_page("member.php?u={0}".format(me.user.id))
	soup = me.soup(profile)
	
	visitors = soup.find(id="collapseobj_visitors")
	footer = visitors.find("div", "alt2 smallfont block_row block_footer")
	count = str(footer.find("strong").string)
	
	post = me.prepare_post(t=args.thread)
	post.message = count
	result = post.post()
	
	print(repr(result))

if __name__ == "__main__":
	forumapi.run(main, options=settings, supported_types=["vbulletin"])
